const webpack = require('webpack');
const path = require('path');
const Html = require('html-webpack-plugin');

module.exports = {
  entry: {
    client: './src/socket-client.js',
    host: './src/socket-host.js',
    main: './src/index.js'
  },
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: '[name].js',
    publicPath: ''
  },
  resolve: {
    alias: {
      assets: path.resolve(__dirname, 'assets')
    }
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules(?!.*react-components))/,
        use: 'babel-loader'
      },
      {
        test: /\.(jpg|jpeg|png|gif|mp4)$/,
        use: 'file-loader'
      }
    ]
  },
  plugins: [
    new Html({
      chunks: ['main'],
      filename: 'index.html',
      template: 'src/template.html'
    }),
    new Html({
      chunks: ['client'],
      filename: 'client.html',
      template: 'src/template.html'
    }),
    new Html({
      chunks: ['host'],
      filename: 'host.html',
      template: 'src/template.html'
    })
  ]
}